package com.baway.biliclitent.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.baway.biliclitent.fragment.ZoneType.RegionTypeRecommendFragment;
import com.baway.biliclitent.model.ZoneBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hcc on 16/8/4 14:12
 * 100332338@qq.com
 * <p/>
 * 分区界面PagerAdapter
 */
public class RegionPagerAdapter extends FragmentStatePagerAdapter {

    private int rid;

    private List<String> titles;

    private List<ZoneBean.DataBeanHeadline.ChildrenBeanHeadline> childrens;

    private List<Fragment> fragments = new ArrayList<>();


    public RegionPagerAdapter(FragmentManager fm, List<String> titles,
                              List<ZoneBean.DataBeanHeadline.ChildrenBeanHeadline> childrens) {
        super(fm);
        this.titles = titles;
        this.childrens = childrens;
        for (int i = 0; i < titles.size(); i++) {
            //进行传值
            RegionTypeRecommendFragment fragment = RegionTypeRecommendFragment.
                    setData(childrens.get(i).getTid());
            fragments.add(fragment);
        }
    }

    @Override
    public Fragment getItem(int position) {

        return fragments.get(position);
    }


    @Override
    public int getCount() {

        return fragments.size();
    }


    @Override
    public CharSequence getPageTitle(int position) {

        return titles.get(position);
    }
}
